# -*- coding: utf-8 -*-

__metaclass__ = type

import random

infinity = 1.0e400

class Struct:
    def __init__(self, **entries):
        self.__dict__.update(entries)

    def __cmp__(self, other):
        if isinstance(other, Struct):
            return cmp(self.__dict__, other.__dict__)
        else:
            return cmp(self.__dict__, other)

    def __repr__(self):
        args = ['%s=%s' % (k, repr(v)) for (k, v) in vars(self).items()]
        return 'Struct(%s)' % ', '.join(args)

def parse_movimento(movimento):
    """Transforma a strin do movimento em uma tupla
    """
    print movimento
    movimento = movimento.strip('\n')
    movimento = movimento.strip()
    jogador, movimentos = movimento.split(':')
    parts = movimentos.split(' ')
    parts = filter(None, parts)
    mvtos = []
    start = None
    for part in parts:
        a, b = part.split('-')
        a = (int(a[0]), a[1])
        b = (int(b[0]), b[1])
        if start is None:
            start = a
            mvtos.append(b)
            continue
        if a not in mvtos:
            mvtos.append(a)
        if b not in mvtos:
            mvtos.append(b)
    end = mvtos[-1]
    if len(mvtos) == 1:
        mvtos = ()
    return jogador, start, end, tuple(mvtos)
